//
//  AllCourseTagView.m
//  yjw-winner
//
//  Created by 隆霁 on 2018/9/30.
//  Copyright © 2018年 Shanghai decade financial information service co., LTD. All rights reserved.
//

#import "AllCourseTagView.h"

@interface AllCourseTagView () {}
@property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *buttons;

@property (nonatomic, strong) id model;
@property (nonatomic, copy) AllCourseTagCallBackBlock block;
@end
@implementation AllCourseTagView
+ (AllCourseTagView *)headView {
    return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([AllCourseTagView class]) owner:self options:nil]lastObject];
}
- (void)awakeFromNib {
    [super awakeFromNib];
    for (UIButton *button in self.buttons) {
        button.layer.masksToBounds = YES;
        button.layer.borderColor = MAIN_COLOR.CGColor;
        button.layer.borderWidth = 0.5;
        button.layer.cornerRadius = 4.0f;
    }
}
- (void)refreshWith:(id)model CallBackBlock:(AllCourseTagCallBackBlock)block {
    self.model = model;
    self.block = block;
}


#pragma mark --mark EVENT

- (IBAction)labelsButtonClick:(UIButton *)sender {
    if (sender.isSelected) {
        return;
    }
    for (UIButton *button in self.buttons) {
        if (button.isSelected) {
            button.selected = NO;
        }
    }
    sender.selected = YES;
    if (self.block) {
        self.block(sender.titleLabel.text);
    }
}

@end
